﻿using System.Runtime.Serialization;
using EzDesk.Core.Model;

namespace EzDesk.Apps.Model.ProjectModule
{
    [DataContract]
    public enum WorkitemStatus
    {
        [EnumMember]
        Ongoing = 0,  // 正在进行中
        [EnumMember]
        Completed = 1,  // 已经完成
        [EnumMember]
        Expired = 2,  // 过期了
        [EnumMember]
        WaitingForConfirm = 3,  // 等待确认
        [EnumMember]
        Ready = 4,  // 没有负责人，等待分配
    }

    public partial class Workitem:ICloneable<Workitem>
    {
        [DataMember]
        public WorkitemStatus Status
        {
            get { return (WorkitemStatus)StatusValue; }
            set { StatusValue = (int)value; }
        }

        [DataMember]
        public string OwnerName { get; set; }
        [DataMember]
        public string CreatorName { get; set; }

        public Workitem Clone()
        {
            return MemberwiseClone() as Workitem;
        }
    }

    public static class WorkItemExt
    {
        public static bool IsSelfWorkitem(this Workitem source)
        {
            return source.CreatorId == source.OwnerId;
        }

    }
}